<!-- 商品导航 -->
<template>
  <div>
    <div id="foot">
      <div class="adressNone" v-if="AdressState == '2' && goods_plugin.goods_stock_judgment">该商品在该地区暂没有库存销售</div>
      <div class="posDiv set-pc-styleLeft" v-if="goods_type == 'reserve_simple_goods'">
        <div class="RightBox" @click="tapReserve">
          立即预约
        </div>
      </div>
      <template v-else-if="goods_type == 'lawyer_platform_goods'">
        <div class="lawyer_platform_goods">
          <div class="lawyer_platform_goods-left">
            <span v-if="lawyer_Info.name">律师:{{ lawyer_Info.name }}</span>
            <span v-if="lawyer_Info.service_type == 'tel'">电话咨询 </span>
            <span v-if="lawyer_Info.service_type == 'line'">在线咨询有效期{{ lawyer_Info.service_day }}天</span>
          </div>
          <div class="lawyer_platform_goods-right" @click="payHandle">
            <div>
              立即购买
            </div>
            <div v-if="lawyer_Info.price">￥{{ lawyer_Info.price }}</div>
          </div>
        </div>
      </template>

      <van-goods-action class="set-pc-styleLeft" v-else>
        <!-- 通过 initAction() 方法设置 -->
        <template v-for="(item, index) in bottom_button">
          <!-- 接口bottom_button字段 循环 -->
          <van-goods-action-button v-if="item.key == 'BuyNow' && !isRent" :key="index" type="danger" :disabled="disabledC(item)" @click="unifyTap(item.key)">
            <template #default>
              <template v-if="(isBuy && !isBegTime) || !isBuy">{{item.name}}</template>
              <template v-if="isBuy && isBegTime">
                距开始还剩
                <van-count-down :time="begTimeStr" class="bottom_time" format="DD 天 HH 时 mm 分 ss 秒">
                  <template #default="timeData">
                    <em style="color: #fff;">{{ timeData.days }} </em> <span style="color: #fff;">天</span>
                    <em style="color: #fff;">
                      {{ timeData.hours }}
                    </em>
                    <b style="color: #fff;">:</b>
                    <em style="color: #fff;">
                      {{ timeData.minutes }}
                    </em>
                    <b style="color: #fff;">:</b>
                    <em style="color: #fff;">
                      {{ Number(timeData.seconds) < 10 ? `0${timeData.seconds}` : timeData.seconds }}
                    </em>
                  </template>
                </van-count-down>
              </template>
            </template>
          </van-goods-action-button>
          <van-goods-action-button :type="actionTypeColor(item.key)" :key="index" :text="item.name" @click="unifyTap(item.key)" :disabled="disabledC(item)" v-else-if="item.class == ''">
          </van-goods-action-button>
          <van-goods-action-icon :key="index" :icon="item.class" :text="item.name" @click="unifyTap(item.key)" :badge="item.key == 'Cart' ? $store.state.cart_num || '' : ''" v-else />
        </template>
        <!-- 收藏图标 配置项：Favorite-->
        <!-- <van-goods-action-icon icon="star" v-if="isShowFavorite" :text="favorite ? '已收藏' : '未收藏'" :color="favorite ? '#ff5000' : '#323233'" @click="onFavorite(favorite)" /> -->
        <!-- 首页图标 配置项：Shop-->
        <!-- <van-goods-action-icon icon="shop-o" v-if="isShowShop" :text="shopText" @click="gotoHome" /> -->
        <!-- 订单图标 配置项：Order-->
        <!-- <van-goods-action-icon icon="orders-o" v-if="isShowOrder" text="订单" @click="gotoOrder" /> -->
        <!-- 购物车图标 配置项：Cart-->
        <!-- <van-goods-action-icon icon="cart-o" v-if="isShowCart" text="购物车" :badge="$store.state.cart_num || ''" @click="gotoCart" /> -->
        <!-- 客服图标 配置项：Chat-->

        <!-- <van-goods-action-icon icon="chat-o" text="客服" @click="clickChat" v-if="isShowChat" />
        <template v-if="isShowtemplateCode03">
          <van-goods-action-button type="warning" text="联系电话" @click="callPhone"></van-goods-action-button>
          <van-goods-action-button type="danger" text="客服" @click="clickChat" />
        </template> -->

        <template v-if="goods_type == 'GroupGoods'">
          <van-goods-action-icon icon="shop-o" v-if="isShowShop" :text="shopText" @click="gotoHome" />
          <van-goods-action-icon text="我的拼团" @click="toMyGroups">
            <template #icon>
              <i class="iconfont icon-31quanbushangpin isgroupIcon"></i>
            </template>
          </van-goods-action-icon>
        </template>
        <!-- 配销券 隐藏加入购物车按钮显示对话按钮 -->
        <!-- <van-goods-action-button type="warning" text="兑换" v-if="!isShowAddCartBtn && distributionCouponBtn" @click="distributionCoupon_buyNow" /> -->
        <!-- 加入购物车按钮 配置项：AddCart-->
        <!-- <van-goods-action-button type="warning" text="加入购物车" v-if="isShowAddCartBtn && !yz_supply_lease" @click="addCart" :disabled="(!isGoods || !isAddCart) || AdressState == '2'" />
        <van-goods-action-button type="danger" text="立即购买" :disabled='yzisDisabled' v-if="isShowAddCartBtn && yz_supply_lease"  @click="yz_supply_leaseBuy" />
        <template v-if="isRent && isRentSetting">
          <van-goods-action-button type="danger" text="立即租赁" @click="yz_supply_leaseBuy" />
        </template> -->
        <!-- --------------------- 按钮分割线  ---------------------  -->

        <!-- 酒店插件 -->
        <!-- <van-goods-action-button type="danger" v-if="goods_type == 'hotelGoods'" text="立即预定" @click="order" /> -->
        <!-- 小猪欢欢项目 二期 -->
        <van-goods-action-button color="#F58220" v-if="goods_type == 'GroupGoods' && goods_info.original_cost_buy_button == '1'" text="原价购买" @click="originalPriceTo(goods_info.goods_id)" />
        <!-- 拼团插件 -->
        <template v-if="(goods_type == 'GroupGoods' || goods_type == 'ywmGroup') && goods_info.status == '1'">
          <van-goods-action-button text="开团卡开团" v-if="goods_type == 'ywmGroup' && goods_info.is_auto_open_button" @click="preOrderM('openCardGroup')" color="#F58220" type="warning" />
          <!-- 开团按钮 -->
          <van-goods-action-button type="warning" v-if="showOpeonBtn" @click="preOrderM('GroupGoods')">
            <template #default>
              {{ $i18n.t("money") }}{{ goodsInfo.vip_level_status && goodsInfo.vip_level_status.status == 1 ? goodsInfo.vip_level_status.word : goods_info.min_price }}<br />
              <div style="font-size: 12px;">一键开团</div>
            </template>
          </van-goods-action-button>
          <van-goods-action-button
            type="danger"
            @click="showGroupMore()"
            v-if="!(goods_type == 'ywmGroup' && !goods_info.is_show_be_being_group) || (goods_type == 'GroupGoods' && goods_info.original_cost_buy_button == '1')"
          >
            <!-- 参团按钮 -->
            <template #default>
              {{ $i18n.t("money") }}{{ goodsInfo.vip_level_status && goodsInfo.vip_level_status.status == 1 ? goodsInfo.vip_level_status.word : goods_info.min_price }} <br />
              <div style="font-size: 12px;">去参团</div>
            </template>
          </van-goods-action-button>
        </template>

        <!-- 珍惠拼拼团插件 -->
        <template v-if="goods_type == 'zhpGroup'">
          <van-goods-action-icon icon="shop-o" :text="shopText" @click="gotoHome" />
          <van-goods-action-icon icon="orders-o" text="订单" @click="gotoOrder" />
          <van-goods-action-button type="warning" v-if="goods_info.is_show_barter == 1" @click="preOrderM('zhpYh')">
            <!-- 参团按钮 -->
            <template #default>
              <template>
                <div style="font-size: 12px;">易兑</div>
              </template>
            </template>
          </van-goods-action-button>
          <van-goods-action-button type="danger" @click="preOrderM('zhpGroup')" :disabled="goods_info.status == 2">
            <!-- 参团按钮 -->
            <template #default>
              <template v-if="goods_info.status != 2">
                {{ $i18n.t("money") }}{{ goodsInfo.vip_level_status && goodsInfo.vip_level_status.status == 1 ? goodsInfo.vip_level_status.word : `${goods_info.min_price}起` }} <br />
                <div style="font-size: 12px;">去参团</div>
              </template>
              <template v-else>已结束</template>
            </template>
          </van-goods-action-button>
        </template>

        <!-- 抢团插件 -->
        <template v-if="goods_type == 'grab_group' && goodsInfo && timestamp > goodsInfo.start_time && timestamp < goodsInfo.end_time">
          <!-- 开团按钮 -->
          <van-goods-action-button type="warning" @click="openOrder(1)" v-if="leader_not_join_invalid == 0">
            <template #default>
              开团<br />
              <div style="font-size: 12px;">(不参与抢团)</div>
            </template>
          </van-goods-action-button>
          <van-goods-action-button type="danger" v-if="leader_not_join_invalid == 1 || leader_partake == 1" @click="openOrder(2)">
            <!-- 参团按钮 -->
            <template #default>
              开团
              <div style="font-size: 12px;" v-if="leader_not_join_invalid == 0">(参与抢团)</div>
            </template>
          </van-goods-action-button>
        </template>
        <!-- 新零售插件 -->
        <template v-if="goods_type == 'newRetailSalesGood'">
          <van-goods-action-icon icon="shop-o" text="首页" @click="gotoHome" />
          <!-- 新零售插件 -->
          <van-goods-action-button type="warning" v-if="this.$route.params.mode == 2" text="代理销售" @click="newRetailBuy('newRetail_1')" />
          <van-goods-action-button type="danger" text="立即购买" @click="newRetailBuy('newRetail_2')" />
        </template>

        <!--付费文件购买后-->
        <!-- <template v-if="goods_type == 'paid_file' && goods_plugin && goods_plugin.paid_file && goods_plugin.paid_file.is_buy === 1">
          <van-goods-action-button type="danger" text="已购买，在页面付费文件中下载" color="#6c6c6c" />
        </template> -->
        <template v-if="goods_plugin && goods_plugin.customized_group">
          <van-goods-action-button
            type="danger"
            text="暂不可购买"
            color="#6c6c6c"
            v-if="goods_info.get_goods && goods_info.get_goods.min_price > Number(goods_plugin && goods_plugin.customized_group && goods_plugin.customized_group.buy_max)"
          />
          <van-goods-action-button type="danger" :disabled="grisTime" @click="yz_supply_leaseBuy" v-else>
            <template #default>
              <template v-if="!grisTime">
                <div>
                  <p>
                    {{ $i18n.t("money") }}
                    {{ goodsInfo.vip_level_status && goodsInfo.vip_level_status.status == 1 ? goodsInfo.vip_level_status.word : goods_info.get_goods && goods_info.get_goods.min_price }}
                  </p>
                  <p>{{buyNowText}}</p>
                </div>
              </template>
              <template v-if="grisTime">
                距开始还剩
                <van-count-down :time="grBegTimeStr" class="bottom_time" format="DD 天 HH 时 mm 分 ss 秒">
                  <template #default="timeData">
                    <em style="color: #fff;">{{ timeData.days }} </em> <span style="color: #fff;">天</span>
                    <em style="color: #fff;">
                      {{ timeData.hours }}
                    </em>
                    <b style="color: #fff;">:</b>
                    <em style="color: #fff;">
                      {{ timeData.minutes }}
                    </em>
                    <b style="color: #fff;">:</b>
                    <em style="color: #fff;">
                      {{ Number(timeData.seconds) < 10 ? `0${timeData.seconds}` : timeData.seconds }}
                    </em>
                  </template>
                </van-count-down>
              </template>
            </template>
          </van-goods-action-button>
        </template>
      </van-goods-action>
    </div>
    <shopListShow
      :showList="supplierListShow"
      v-if="goods_info.get_goods && goods_info.get_goods.supplier"
      :supplierDataId="supplierDataId"
      v-on:close="closeShopList"
      :supplier="goods_info.get_goods.supplier"
    ></shopListShow>
    <cservice-popup :show="show1" :cservice="cservice" :service_mobile="service_mobile" :service_QRcode="service_QRcode" @close="show1 = false"></cservice-popup>
    <time-appointment-popup
      v-if="goods_type == 'reserve_simple_goods'"
      ref="AppointmentPopup"
      :goods_info="goods_info"
      :plugin="goods_plugin.reserve_simple_goods"
      :show="appointment_show"
      @close="appointment_show = false"
    />
  </div>
</template>

<script>
import { Toast } from "vant";
import shopListShow from "./plugin/shopListShow.vue";
import cservicePopup from "./plugin/cservicePopup";
import timeAppointmentPopup from "./plugin/timeAppointmentPopup";
import { bindDrainageScene } from "../../../fun/modules/drainage_scene";
const SUBMIT_ACTION_CART = "-1"; //添加到购物车
const SUBMIT_ACTION_BUY = "-2"; //立即购买
var submitActionTag = "";
var goods_id = 0;
var level_id = 0;
var optionsId = 0;
export default {
  components: { cservicePopup, shopListShow, timeAppointmentPopup },
  props: {
    appointment_show: {
      type: Boolean,
      default: false
    },
    goods_info: {
      type: Object,
      default: () => ({})
    },
    goods_plugin: {
      type: Object,
      default: () => ({})
    },
    isRent: {
      type: Boolean,
      default: false
    },
    isGoods: {
      type: Boolean,
      default: false
    },
    goods_type: {
      type: String,
      default: ""
    },
    // 倒计时
    isBuy: {
      type: Boolean,
      default: false
    },
    isTime: {
      type: Boolean,
      default: false
    },
    isBegTime: {
      type: Boolean,
      default: false
    },
    begTimeStr: {
      type: String,
      default: ""
    },
    endTimeStr: {
      type: String,
      default: ""
    },
    grisTime: {
      type: Boolean,
      default: false
    },
    grBegTimeStr: {
      type: String,
      default: ""
    },
    favoriteStatus: {
      type: Boolean, //收藏状态
      default: false
    },
    loaging: {
      type: Boolean,
      default: false
    },
    cservice: {
      //客服
      type: String,
      default: ""
    },
    service_mobile: {
      type: String,
      default: ""
    },
    service_QRcode: {
      type: String,
      default: ""
    },
    supplierDataId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      //按钮显示条件
      isShowFavorite: false, //收藏
      isShowShop: false, //首页
      isShowCart: false, //购物车
      isShowChat: false, //客服
      isShowOrder: false, //订单
      isShowAddCart: false, //加入购物车
      isShowBuyNow: false, //立即购买按钮
      isShowtemplateCode03: false,//详情模板3，固定联系电话和客服

      isDisabled: false, //禁用按钮
      yzisDisabled: false,
      isDisabledText: "",

      isShowAddCartBtn: false, //是否显示加入购物车按钮

      isMiniApp: window.isMiniprogram ? true : false,

      show1: false, //客服弹窗显示
      nocart: true,
      favorite: false, //收藏状态

      isAddCart: false,
      isPendingOrder: false, //挂单商品
      //* 云库存商品
      fromStock: "",
      goodsInfo: {},
      // goods_info: {},

      option_level_id: 0, //拼团插件：规格层级id
      leader_partake: 1, //抢团插件：团长是否参与中奖 1-是 2-否
      leader_not_join_invalid: 0, //为1时不显示“不参与抢团”按钮
      isCheckActivity: true, //抢团插件：下单前检查客户今天是否超出限制

      levelModel: 0, //新零售 销售代理套餐等级

      timestamp: Date.parse(new Date()) / 1000, //获取当前时间戳
      original_cost_buy_button: false,
      reserveData: {
        name: "",
        time: "",
        price: "",
        optionsId: ""
      },
      plugin_setting: "",
      lawyer_Info: {
        l_id: "",
        status: "",
        name: "",
        price: "",
        service_day: "",
        service_type: "",
        l_name: "",
        lf_id: "",
        l_name: "",
        lf_province_name: "",
        lf_city_name: "",
        lf_area_name: "",
        lf_street_name: "",
        lf_address_detail: ""
      },
      AdressState:'1',//2无货禁用，1有货
      supplierListShow:false,
      yz_supply_lease:false,
      isRentSetting:false,
      bottom_button:[],
      buyNowText:''//自定义购买文字
    };
  },
  mounted() {},
  // created() {},
  // activated() {},
  deactivated() {
    this.$emit("deactivatedShowGood", false); //如果不设置，第二次进入不会触发监听到当前的watch里的loaging
  },
  computed: {
    actionTypeColor(key){
      //item.key == 'AddCart' ? 'warning' : 'danger'
      return function(key){
        if(key == 'AddCart' || key == 'distributionCoupon'){
          return 'warning'
        }else{
          return 'danger'
        }
      }
    },
    disabledC(item) {
      return function(item) {
        if (item.key == "BuyNow" || item.key == 'AddCart') {
          if ((this.isBuy && this.isBegTime) || this.AdressState == "2") {
            return true;
          }
          return item.disabled
        }
        if (this.yzisDisabled) {
          return this.yzisDisabled;
        } else {
          return !item.status;
        }
      };
    },
    //底部一键开团是否隐藏
    showOpeonBtn() {
      let that = this;
      if (that.goods_info.menu_show == 0) {
        return true;
      } else if (that.goods_info.menu_show == 1 && that.goods_info.has_many_team_count < that.goods_info.hide_num) {
        return true;
      } else {
        return false;
      }
    },
    appointmentLang() {
      if (this.$store.state.shopLanguage.reserve_simple) {
        return this.$store.state.shopLanguage.reserve_simple;
      } else {
        return { reserve_obj: "预约人员", service: "服务" };
      }
    },
    shopText() {
      if (this.goods_type == "GroupGoods" || this.goods_type == "ywmGroup") {
        return "主页";
      }
      if (this.goods_type == "supplierGoods") {
        return "店铺";
      }
      return "首页";
    }
  },
  watch: {
    loaging: function(newV, oldV) {
      this.init();
    },
    goods_plugin: function(newV, oldV) {
      this.yz_supply_lease = newV?.yz_supply_lease?.is_yz_supply_lease == 1 ? true : false;
    },
    isRent(nval, oval) {
      if (nval) {
        let plugin = localStorage.getItem("plugin_setting") ? JSON.parse(localStorage.getItem("plugin_setting")) : {};
        if (plugin.lease_toy) {
          this.isRentSetting = plugin.lease_toy.is_immediate_lease;
        }
      } else {
        this.isRentSetting = {};
      }
    }
  },
  methods: {
    yz_supply_leaseBuy() {
      this.buyNow();
    },
    toMyGroups() {
      this.$router.push(this.fun.getUrl("MyGroups", {}));
    },
    lawyerInfo(data) {
      this.lawyer_Info.l_id = data.id;
      this.lawyer_Info.status = data.status;
      this.lawyer_Info.name = data.name;
      if (data.status == 0) {
        this.lawyer_Info.price = "";
      } else {
        this.lawyer_Info.price = data.service_data.amount;
      }
      this.lawyer_Info.service_day = data.service_data.day || "";
      this.lawyer_Info.service_type = data.service_data.type;
      this.lawyer_Info.l_name = data.name;
      this.lawyer_Info.lf_name = data.lawyer_firm.name;
      this.lawyer_Info.lf_id = data.lf_id;
      this.lawyer_Info.lf_province_name = data.lawyer_firm.province_name;
      this.lawyer_Info.lf_city_name = data.lawyer_firm.city_name;
      this.lawyer_Info.lf_area_name = data.lawyer_firm.area_name;
      this.lawyer_Info.lf_street_name = data.lawyer_firm.street_name;
      this.lawyer_Info.lf_address_detail = data.lawyer_firm.address_detail;
    },
    closeShopList() {
      this.supplierListShow = false;
    },
    init() {
      this.yzisDisabled = false;
      this.favorite = this.favoriteStatus;
      this.initAction(); //配置商品类型显示对应按钮
      this.plugin_setting = localStorage.getItem("plugin_setting") ? JSON.parse(localStorage.getItem("plugin_setting")) : "";
      this.buyNowText = this.fun.getCustomTextLang("goods.buy_now", "立即购买"); //获取后台自定义购买按钮文字
      this.goodsInfo = this.goods_info.get_goods;
      if (this.goods_info.get_hotel_info) this.goodsInfo = { ...this.goods_info.get_goods, ...this.goods_info.get_hotel_info.goods };

      if (this.goods_type == "GroupGoods" || this.goods_type == "ywmGroup") {
        goods_id = this.goodsInfo.id;
        if (this.goods_info.status != "1") {
          this.isDisabled = true;
          this.isDisabledText = this.goods_info.status == "0" ? "活动未开始" : "活动已结束";
        }
      } else if (this.goods_type == "groupWorkGood") {
        goods_id = this.goods_info.goods_id;
      } else {
        goods_id = this.$route.params.id;
      }

      if (this.goods_type == "grab_group") {
        this.leader_partake = this.goods_info.leader_partake;
        this.leader_not_join_invalid = Number(this.goods_info.leader_not_join_invalid) || 0;
        if (this.timestamp < this.goodsInfo.start_time || this.timestamp > this.goodsInfo.end_time) {
          this.isDisabled = true;
          this.isDisabledText = this.timestamp < this.goodsInfo.start_time ? "活动未开始" : "活动已结束";
        }
      }

      if (
        this.plugin_setting &&
        this.plugin_setting.yz_supply_camilo_resources &&
        (this.plugin_setting.yz_supply_camilo_resources.is_ios_sell === 1 || this.plugin_setting.yz_supply_camilo_resources.is_ios_sell === "1")
      ) {
        // 卡券商品 并开启 IOS禁用
        if (this.goods_info.get_goods.plugin_id == 140 && this.fun.isIosOrAndroid() === "ios") {
          this.isShowBuyNow = false;
          this.isDisabled = true;
          this.isDisabledText = "立即购买";
        }
      }
      if (this.plugin_setting?.yz_supply_lease?.is_ios_sell == "1") {
        if (this.goods_info.get_goods.plugin_id == 164 && this.fun.isIosOrAndroid() === "ios") {
          this.yzisDisabled = true;
        }
      }
      if (this.goods_plugin && this.goods_plugin.month_buy_limit && this.goods_plugin.month_buy_limit.can_buy !== undefined && !this.goods_plugin.month_buy_limit.can_buy) {
        // 海诚-商品分类会员等级限购#89586
        this.isShowBuyNow = false;
        this.isDisabled = true;
        this.isDisabledText = "立即购买";
      }

      if (this.goodsInfo?.buy_limit?.status == 1 && this.goodsInfo?.buy_limit?.end_time == 0) {
        // 限时购时间段
        this.isShowAddCartBtn = false;
        this.isShowBuyNow = false;
        this.isDisabled = true;
        this.isDisabledText = "暂不可购买";
      }

      //挂单商品
      if (!this.fun.isTextEmpty(this.$route.query.kind) && this.$route.query.kind == "POrder") {
        this.isPendingOrder = true;
      } else {
        this.isPendingOrder = false;
      }
      if (!this.fun.isTextEmpty(this.$route.query.nocart) || this.$route.query.fromStock || this.goods_type === "yunqian_api") {
        this.nocart = false;
      } else {
        this.nocart = true;
      }

      //百网-存货服务
      if (this.goods_plugin && this.goods_plugin.plugin_stock_service) {
        this.isShowAddCartBtn = false;
        this.isShowCart = false;
      }
      if (this.$route.query.tag && this.$route.query.tag == "vending_machine") {
        this.isShowAddCartBtn = false;
        this.isShowCart = false;
      }
      // 云库存带了这个参数点击加入购物车就提示不能加入购物车
      this.fromStock = this.$route.query.fromStock;
      // this.setIsAddCart();
      if (this.goods_type == "paid_file" && this.goods_plugin?.paid_file?.is_buy === 1) {
        this.isShowAddCartBtn = false;
        this.isShowBuyNow = false;
      }
      if (this.goods_plugin?.customized_group) {
        this.isShowAddCartBtn = false;
        this.isShowBuyNow = false;
        this.isShowCart = false;
      }
      if(this.goods_plugin && this.goods_plugin.distribution_coupon && this.goods_plugin.distribution_coupon.active != 0){
        this.isShowAddCartBtn = false;
        this.distributionCouponBtn = true;
        this.distributionCoupon_buyNowStatus = false;
      }
    },
    childAdressPost(e) {
      // 接受是否禁用加入购物车和立即下单
      this.AdressState = e;
    },
    originalPriceTo(kid) {
      this.$router.push(this.fun.getUrl("goods", { id: kid }));
    },
    initAction() {
      if (this.goods_info?.bottom_button) {
        this.goods_info.bottom_button.forEach(ele => {
          if(ele.key == "Favorite"){
            if(this.favorite){
              ele.class="star"
            }else{
              ele.class="star-o"
            }
          }
        });
        let newlist = this.goods_info.bottom_button.filter(item => item.name != "客服")
        this.bottom_button = newlist;
      }
      // Favorite:收藏||Shop：首页||Cart:购物车||Chat:客服||AddCart：加入购物车按钮||BuyNow: 立即购买按钮
      // let handleType = [];
      // let actionArr = new Map([
      //   ["hotelGoods", ["Favorite", "Chat"]],
      //   ["GroupGoods", ["Shop"]],
      //   ["ywmGroup", ["Shop"]],
      //   ["grab_group", ["Shop"]],
      //   ["DistributionGoods", []],
      //   ["newRetailSalesGood", ["Shop"]],
      //   ["appointment_goods", ["Shop", "Chat", "BuyNow"]],
      //   ["yunqian_api", ["Shop", "Chat", "BuyNow"]],
      //   ["store_projects_goods", ["Shop", "Chat", "BuyNow"]],
      //   ["zhpGroup", ["Shop", "Order"]],
      //   ["paid_file", ["Shop", "Cart", "Chat", "AddCart", "BuyNow"]],
      //   ["collection-center", ["Shop", "Cart", "Chat", "BuyNow"]]
      // ]);
      // if (actionArr.has(this.goods_type)) {
      //   //是否有配置，true表示actionArr数据里有定义,值为显示图标/按钮的配置项名称
      //   handleType = actionArr.get(this.goods_type);
      //   console.log(handleType);
      // } else {
      //   let templateCode = this.$store.state.temp.item.ViewSet?.goods?.code?.substring(5) || "01";
      //   if (templateCode != "03") handleType = ["Shop", "Cart", "Chat", "AddCart", "BuyNow"];
      //   if (templateCode == "03") handleType = ["Shop", "templateCode03"];
      // }

      // handleType.forEach(item => {
      //   this[`isShow${item}`] = true;
      // });

      // if (this.goods_info.get_goods && this.goods_info.get_goods.plugin_id == 140) {
      //   this[`isShowCart`] = false; //plugin_id = 140 时商品详情页不显示购物车按钮
      // }

      if (this.goods_type == "supplierGoods" && this.goods_info.get_goods.supplier && Number(this.goods_info.get_goods.supplier.is_open) == 0) {
        this.isShowShop = false; //供应商关闭了聚合页【#90225】
      }

      // if (
      //   this.isShowAddCart &&
      //   !this.isBegTime &&
      //   this.nocart &&
      //   !this.isPendingOrder &&
      //   this.goods_info.get_goods &&
      //   this.goods_info.get_goods.plugin_id != 72 &&
      //   this.goods_info.get_goods.plugin_id != 140 &&
      //   this.goods_plugin.is_special != 1
      // ) {
      //   this.isShowAddCartBtn = true; //加入购物车按钮
      // }
      if (this.$route.params.debtId) {
        this.isShowAddCartBtn = false;
      }
    },
    // //判断是否能加入购物车 perf#19406 禁用判断由后端判断bottom_button
    // setIsAddCart() {
    //   //为空是老数据默认值问题
    //   if (this.fun.isTextEmpty(this.goodsInfo.buy_way) || this.goodsInfo.buy_way == "0") {
    //     this.isAddCart = true;
    //   }

    //   //不能加入 金币产品
    //   if (this.goodsInfo.buy_way == 1) {
    //     this.isAddCart = false;
    //   }
    // },
    //跳转购物车
    gotoCart() {
      this.$router.push(this.fun.getUrl("cart", {}));
    },
    clickChat() {
      let setServicePlugin = this.fun.isTextEmpty(this.service_mobile) && this.fun.isTextEmpty(this.service_QRcode);
      if (this.fun.isTextEmpty(this.cservice) && setServicePlugin) {
        return this.$toast("抱歉，暂未设置客服信息");
      }
      if (!this.fun.isTextEmpty(this.cservice) && setServicePlugin) {
        //只设置了客服链接，直接跳转
        let _cservice = this.cservice;
        if (this.cservice && this.cservice.indexOf("chatWindow") >= 0) {
          _cservice = this.cservice + "&goods_id=" + this.$route.params.id;
        }
        if (this.fun.isCPS()) {
          if (this.fun.isIosOrAndroid() === "ios") {
            //
          } else {
            try {
              serviceClick();
              window.open(_cservice,'_blank');
              return;
            } catch (error) {
              window.location.href = _cservice;
              return;
            }
          }
        }
        window.location.href = _cservice;
        return;
      }
      this.show1 = true;
    },
    //加入购物车
    addCart() {
      if (this.isBuy && this.isBegTime) {
        Toast("该商品还没到购买时间");
        return;
      }
      if (this.fromStock) {
        Toast("该商品无法加入到购物车");
        return;
      }
      //价格权限
      if (this.goodsInfo.vip_level_status && this.goodsInfo.vip_level_status.status == 1) {
        Toast(this.goodsInfo.vip_level_status.tips);
        return;
      }
      $http.get("member.member.isValidatePageGoods", {}).then(response => {
        if (response.result === 1) {
          if (this.goodsInfo.has_one_invite_page && this.goodsInfo.has_one_invite_page.status === 1 && response.data.is_invite === 0) {
            this.$router.push(this.fun.getUrl("Inviter", {}, { fromGood: 1 }));
            return;
          }
          // if (!this.isAddCart) {
          //   return;
          // }
          // if (!this.isGoods) {
          //   Toast("商品已下架或不存在");
          //   return;
          // }

          submitActionTag = SUBMIT_ACTION_CART;
          this.$emit("popupModeshowChild", true);
          // //判断是否有规格
          // if (this.goodsInfo.has_option == 1) {
          //   //有规格
          //   this.popupSpecs = true;
          // } else {
          //   //无规格
          //   //处理参数
          //   optionsId = "";
          //   this.addCartRequest(goods_id, optionsId, this.goodsCount);
          // }
        }
      });
    },
    tapReserve() {
     if (this.fun.isTextEmpty(this.reserveData?.item?.service_id)) {
        Toast("请选择预约人员");
        return;
      }
      this.appointment_show = true;
      this.$refs['AppointmentPopup'].opended_poup();

      // if (this.fun.isTextEmpty(this.reserveData.time)) {
      //   Toast("请选择预约时间");
      //   return;
      // }

      // let json_data = {
      //   goodsId: this.goods_info.get_goods.id,
      //   optionsId: this.reserveData.item.goods_option_id,
      //   total: "1",
      //   tag: "timeAppoint",
      //   reserveDataName: this.reserveData.item.name,
      //   reserveItem: this.reserveData.item,
      //   reserveDate: this.reserveData.time
      // };
      // if (this.fromStock) {
      //   json_data.fromStock = this.fromStock;
      // }
      // this.$router.push(this.fun.getUrl("goodsorder", {}, json_data));
    },
    toWarning() {
      if (
        this.plugin_setting &&
        this.plugin_setting.yz_supply_camilo_resources &&
        (this.plugin_setting.yz_supply_camilo_resources.is_ios_sell === 1 || this.plugin_setting.yz_supply_camilo_resources.is_ios_sell === "1")
      ) {
        if (this.goods_info.get_goods.plugin_id == 140 && this.fun.isIosOrAndroid() === "ios") {
          this.$dialog
            .confirm({
              message: "因平台规则限制，IOS端不支持购买虚拟商品；如需帮助，请联系客服。",
              confirmButtonText: "联系客服"
            })
            .then(() => {
              this.clickChat();
            })
            .catch(() => {
              //cancel
            });
        }
      }
    },
    checkPrice_difference_pool(basic_info) {
      return new Promise((resolve, reject) => {
        $http.get("plugin.price-difference-pool.frontend.modules.pool.controllers.validate.index", {}).then(
          response => {
            if (response.result === 1) {
              resolve(true);
            } else {
              this.$dialog
                .confirm({ message: `${basic_info.price_difference_pool_name}为负数，请充值后再购买`, confirmButtonText: `去${basic_info.price_difference_pool_name}` })
                .then(() => {
                  this.$router.push(this.fun.getUrl("priceDifferencePool", {}, {}));
                })
                .catch(() => {
                  //取消
                });
              resolve(false);
            }
          },
          response => {
            this.$dialog.alert({ message: response.msg });
          }
        );
      });
    },
    verifyAddress(data ={}) {
      // 验证配送地址
      return new Promise((resolve, reject) => {
        $http.post("cart.pre-goods-verify", data).then(
          response => {
            if (response.result === 1) {
              resolve(true);
            } else {
              this.$dialog
                .confirm({ message: response.msg, confirmButtonText: `更换地址` ,cancelButtonText: '确定'})
                .then(() => {
                  this.$store.commit("setGood_delivery_address_show", true);
                })
                .catch(() => {
                  //取消
                });
              resolve(false);
            }
          },
          response => {
            this.$dialog.alert({ message: response.msg });
          }
        );
      });
    },
    //立即购买
    async buyNow(key='') {
      let basic_info = JSON.parse(localStorage.getItem("yz_basic_info"));
      let that = this;
      if(key == 'distributionCoupon'){
        // 配销券
        this.distributionCoupon_buyNowStatus = true;
      }else{
        this.distributionCoupon_buyNowStatus = false;
      }
      if (this.isBuy && this.isBegTime) {
        Toast("该商品还没到购买时间");
        return false;
      }
      //价格权限
      if (this.goodsInfo.vip_level_status && this.goodsInfo.vip_level_status.status == 1) {
        Toast(this.goodsInfo.vip_level_status.tips);
        return false;
      }
      if (basic_info.price_difference_pool) {
        if ((await this.checkPrice_difference_pool(basic_info)) == false) {
          return;
        }
      }

      $http.get("member.member.isValidatePageGoods", {}).then(
        response => {
          if (response.result === 1) {
            if (this.goodsInfo.has_one_invite_page && this.goodsInfo.has_one_invite_page.status === 1 && response.data.is_invite === 0) {
              this.$router.push(this.fun.getUrl("Inviter", {}, { fromGood: 1 }));
              return;
            }
            if (!this.isGoods) {
              Toast("商品已下架或不存在");
              return;
            }
            submitActionTag = SUBMIT_ACTION_BUY;
            this.$emit("popupModeshowChild", true);
          } else {
            that.$dialog.alert({ message: response.msg });
          }
        },
        response => {
          that.$dialog.alert({ message: response.msg });
        }
      );
    },
    //提交确认
    async submitAction(options_id, goodsCount, cardId, optionsMaxCount, levelsId, option_level_id, status) {
      optionsId = options_id;
      this.goodsCount = goodsCount;

      if(this.goodsInfo.delivery_address&&this.goodsInfo.delivery_address.is_delivery_address) {
        // 后台开关位置：商品-基础设置-显示配送地址
        let delivery_address = this.$store.state.goods.delivery_address;
        let isVerifyAddress = await this.verifyAddress({address: encodeURIComponent(JSON.stringify(delivery_address)), goods_id: goods_id,option_id: options_id, total: goodsCount});
        if(!isVerifyAddress) return;//当前地址在禁运区域
      }

      this.$emit("popupModeshowChild", false);
      if (status) return; //如果是详情规格点击进来的就不跳去预下单页面
      if (submitActionTag == SUBMIT_ACTION_CART) {
        //购物车网络处理
        this.addCartRequest(goods_id, options_id, goodsCount);
      } else if (submitActionTag == SUBMIT_ACTION_BUY) {
        //立即购买处理
        this.buyNowRequest(goods_id, options_id, goodsCount);
      } else if (submitActionTag == "GroupGoods") {
        //拼团开团
        level_id = levelsId;
        this.option_level_id = option_level_id;
        this.openTeam(goods_id, options_id, goodsCount, optionsMaxCount);
      } else if (submitActionTag == "openCardGroup") {
        //拼团开团
        level_id = levelsId;
        this.option_level_id = option_level_id;
        this.openCardGroup(goods_id, options_id, goodsCount, optionsMaxCount);
      } else if (submitActionTag == "snatchLeader" || submitActionTag == "snatchGroup") {
        this.checkActivity();
      } else if (submitActionTag == "newRetail_1" || submitActionTag == "newRetail_2") {
        this.newRetailOrder();
      } else if (submitActionTag == "zhpGroup") {
        this.zhpGroupOrder();
      }
    },
    //加入购物车网络操作
    addCartRequest(_goodsId, _optionsId, _total) {
      if (this.goodsInfo.has_option == 1 && this.fun.isTextEmpty(_optionsId)) {
        //规格商品需optionsId 才能下单
        Toast("请选择规格");
        return;
      }
      if (_total <= 0) {
        this.$emit("popupModeshowChild", false);
        Toast("请选择商品数量");
        return;
      }

      let that = this;
      let goods = [];
      goods.push(_goodsId);
      let jsons = {
        goods_ids: JSON.stringify(goods)
      };
      $http.get("from.div-from.isDisplay", jsons, "加载中").then(
        response => {
          if (response.result === 1) {
            if (response.data.status && !response.data.member_status) {
              that.$dialog
                .confirm({ message: "购买跨境商品,请补充您的个人信息" })
                .then(() => {
                  that.$router.push(
                    that.fun.getUrl("myinfo", {
                      tag: "cart",
                      goodsId: _goodsId,
                      optionsId: _optionsId,
                      total: _total
                    })
                  );
                })
                .catch(() => {});
            } else {
              that.addCartReq(_goodsId, _optionsId, _total);
            }
          } else {
            console.log(response.msg);
          }
        },
        response => {
          console.log(response);
          that.isGoods = false;
        }
      );
    },

    addCartReq(_goodsId, _optionsId, _total) {
      let json = { goods_id: _goodsId, total: _total, option_id: _optionsId };
      $http.get("member.member-cart.store", json, "添加中...").then(
        response => {
          if (response.result == 1) {
            this.$store.commit("setCartNum", response.data.cart_num);
            Toast(response.msg);
          } else {
            this.$dialog.alert({ message: response.msg });
          }
        },
        response => {
          console.log(response);
        }
      );
    },

    //立即购买网络操作
    buyNowRequest(_goodsId, _optionsId, _total) {
      let isBindDrainageScene = bindDrainageScene({
        scene: 1,
        title: this.goodsInfo.title,
        goods_id: _goodsId
      });
      if (!isBindDrainageScene) return; //爆客码绑定场景

      if (this.goodsInfo.has_option == 1 && this.fun.isTextEmpty(_optionsId)) {
        //规格商品需optionsId 才能下单
        Toast("请选择规格");
        return;
      }

      if (_total <= 0) {
        Toast("请选择商品数量");
        return;
      }

      if (
        this.goods_type === "appointment_goods" ||
        this.goods_type === "yun_contract_lock_goods" ||
        this.goods_type === "yun_sign_goods" ||
        this.goods_type === "yunqian_api" ||
        this.goods_type === "store_projects_goods" ||
        this.goods_type === "map-marker" ||
        this.goods_type === "collection-center" ||
        this.goods_type === "check_in_rebate"
      ) {
        submitActionTag = this.goods_type;
      } else {
        submitActionTag = SUBMIT_ACTION_BUY;
      }
      if (this.isRent && !this.yz_supply_lease) {
        submitActionTag = "rentBuy";
      }
      if (this.yz_supply_lease) {
        submitActionTag = "yzlease";
      }
      console.log(submitActionTag, "submitActionTag");

      //请求保税商品接口
      let that = this;
      let goods = [];
      goods.push(_goodsId);
      let jsons = {
        goods_ids: JSON.stringify(goods)
      };
      $http.get("from.div-from.isDisplay", jsons, "加载中...").then(
        response => {
          if (response.result == 1) {
            let json_data = {
              goodsId: _goodsId,
              optionsId: _optionsId,
              total: _total
            };
            if (response.data.status && !response.data.member_status) {
              that.$dialog
                .confirm({ message: "购买此商品,请补充您的个人信息" })
                .then(() => {
                  json_data.tag = submitActionTag;
                  that.$router.push(that.fun.getUrl("myinfo", json_data));
                })
                .catch(() => {});
            } else {
              if (that.isPendingOrder) {
                //挂单商品
                json_data.tag = "POrder";
                json_data.fromStock = that.fromStock;
              } else {
                //普通商品
                json_data.tag = submitActionTag;
                if (that.fromStock) {
                  json_data.fromStock = that.fromStock;
                }
                if (that.$route.params.activity_id) {
                  json_data.activity_id = that.$route.params.activity_id;
                }
              }
              if (that.$route.query.is_retail) {
                json_data.is_retail = that.$route.query.is_retail;
              }
              if (this.$route.params.debtId) {
                that.$router.push(that.fun.getUrl("debtgoodsorder", { debtId: this.$route.params.debtId }, json_data));
                return;
              }
              if (this.$route.query.tag && this.$route.query.tag == "vending_machine") {
                json_data.tag = "vending_machine";
                json_data.machineId = this.$route.query.machineId;
              }
              if (this.$route.query.tag && this.$route.query.tag == "custom") {
                json_data.tag = "custom";
                json_data.customized_group_id = this.goods_plugin?.customized_group?.group_id;
              }
              if(this.goods_plugin && this.goods_plugin.distribution_coupon != 0 && this.distributionCoupon_buyNowStatus){
                this.beforeCheck(json_data);
                return
              }
              if(this.$route.query.device_id){
                json_data.device_id = this.$route.query.device_id;
              }
              if(this.$route.query.cargo_road_id){
                json_data.cargo_road_id = this.$route.query.cargo_road_id;
              }
              if(this.$route.name == 'purchasingCenterGood'){
                json_data.tag = "purchasingCenterNow"
              }
              that.$router.push(that.fun.getUrl("goodsorder", {}, json_data));
            }
          } else {
            console.log(response.msg);
          }
        },
        response => {
          console.log(response);
        }
      );
    },
    async beforeCheck(json_data){
      let json = { goods_id: json_data.goodsId, total:json_data.total};
      if(json_data.optionsId){
        json.options_id = json_data.optionsId;
      }
      await $http.get("plugin.distribution-coupon.api.goods-buy.before-check", json, "加载中...").then((response)=>{
        console.log(response)
        if(response.result == 1){
          json_data.tag = 'distribution_coupon';
          this.$router.push(this.fun.getUrl("goodsorder", {}, json_data));
        }else{
          this.$toast(response.msg)
        }
      })
    },
    // distributionCoupon_buyNow(){
    //   this.buyNow('distributionCoupon');
    // },
    // 酒店下单
    order() {
      this.$router.push(
        this.fun.getUrl(
          "HotelGoodsOrder",
          {},
          {
            end: this.$route.query.end,
            start: this.$route.query.start,
            id: this.goodsInfo.hotel_id,
            goods_id: this.$route.params.id
          }
        )
      );
    },

    // 同意处理商品底部导航点击事件
    unifyTap(typeUnif) {
      console.log(typeUnif);
      console.log()
      switch (typeUnif) {
        case "Shop":
          this.gotoHome();
          break;
        case "Cart":
          this.gotoCart();
          break;
        case "Chat-button":
        case "Chat":
          this.clickChat();
          break;
        case "AddCart":
          if(this.goods_info.get_goods.has_one_brand && (this.goods_info.get_goods.has_one_brand.name == '创维' || this.goods_info.get_goods.has_one_brand.name == '红旗')){
            this.$toast("请到线下购买！")
            return
          }
          this.addCart();
          break;
        case "BuyNow":
          if(this.goods_type == 'hotelGoods'){
            this.$emit('hotelOrderBtn');
            // perf#47986 酒店商品新增入住时间选择，立即预定在selfParameterServicetag组件处理
            return
          }
          if(this.goods_info.get_goods.has_one_brand && (this.goods_info.get_goods.has_one_brand.name == '创维' || this.goods_info.get_goods.has_one_brand.name == '红旗')){
            this.$toast("请到线下购买！")
            return
          }
          
          this.buyNow();
          break;
        case "PhoneBtn":
          this.callPhone();
          break;
        case "Favorite":
          this.onFavorite(this.favorite);
          break;
        case "distributionCoupon":
          this.buyNow('distributionCoupon');
          break;
        default:
          break;
      }
    },
    // 收藏==========================
    //收藏操作
    onFavorite(isFavorite) {
      if (!this.isGoods) {
        Toast("商品已下架或不存在");
        return;
      }
      // isFavorite ? this.removeFavorite() : this.addFavorite();
      let url = isFavorite ? "member.member-favorite.destroy" : "member.member-favorite.store";
      $http.get(url, { goods_id: goods_id }, ".").then(
        response => {
          if (response.result == 1) {
            this.favorite = !isFavorite;
            if(this.bottom_button){
              this.bottom_button.forEach(ele => {
                if(ele.key == "Favorite"){
                  if(this.favorite){
                    ele.class="star"
                  }else{
                    ele.class="star-o"
                  }
                }
              });
              this.bottom_button = this.bottom_button;
            }
            Toast(`${isFavorite ? "取消收藏" : "收藏成功"}`);
            this.$emit("changeFavorite", this.favorite);
          }
        },
        response => {
          console.log(response);
        }
      );
    },

    preOrderM(type) {
      let isBindDrainageScene = bindDrainageScene({
        scene: 8,
        title: this.goodsInfo.title
      });
      if (!isBindDrainageScene) return; //爆客码绑定场景

      if (type == "zhpYh") {
        this.$router.push(this.fun.getUrl("zhpMyGroups", { status: 1 }));
        return;
      }
      //价格权限
      if (this.goodsInfo.vip_level_status && this.goodsInfo.vip_level_status.status == 1) {
        Toast(this.goodsInfo.vip_level_status.tips);
        return false;
      }
      if ((type === "GroupGoods" || type === "ywmGroup") && this.goods_info.join_status === false) {
        Toast({
          message: "今日该活动已达到参与次数",
          icon: "info-o"
        });
        return false;
      }
      submitActionTag = type;
      this.$emit("popupModeshowChild", true);
    },
    openTeam(goods_id, optionsId, goodsCount, optionsMaxCount) {
      let that = this;
      this.goodsId = goods_id;

      if (this.goodsCount > this.groupStock) {
        Toast("库存不足");
        this.goodsCount = this.groupStock;
        return;
      }
      if (optionsMaxCount != 0 && this.goodsCount > optionsMaxCount) {
        // Toast("库存不足");
        Toast(`抱歉，该商品限购${optionsMaxCount}件`);
        this.goodsCount = optionsMaxCount;
        return;
      }
      if (this.goodsCount <= 0) {
        Toast("商品数量不能小于0");
        this.goodsCount = 1;
        return;
      }

      if (this.fun.isTextEmpty(level_id)) {
        Toast("请选择开团点");
        console.log("请选择开团点");
        return;
      }

      let goods = [];
      goods.push(that.goodsId);
      $http.get("from.div-from.isDisplay", { goods_ids: JSON.stringify(goods) }, "加载中").then(response => {
        if (response.result === 1) {
          if (response.data.status && !response.data.member_status) {
            that.$dialog
              .confirm({ message: "购买跨境商品,请补充您的个人信息" })
              .then(() => {
                that.$router.push(
                  that.fun.getUrl("myinfo", {
                    tag: "",
                    goodsId: that.goodsId,
                    optionsId: optionsId,
                    total: that.goodsCount
                  })
                );
              })
              .catch(() => {});
          } else {
            let _json = {
              tag: "-2",
              goodsId: that.goodsId,
              optionsId: optionsId,
              total: that.goodsCount,
              level_id: level_id,
              option_level_id: that.option_level_id
            };
            if (that.$route.params.store_id && Number(that.$route.params.store_id) != 0) {
              _json.groupStoreID = that.$route.params.store_id;
            }
            if (that.$route.query.share_uid && Number(that.$route.query.share_uid) != 0) {
              _json.share_uid = that.$route.query.share_uid;
            }
            if (that.$route.query.activity_id && Number(that.$route.query.activity_id) != 0) {
              _json.activity_id = that.$route.query.activity_id;
            }
            if (that.goods_type === "ywmGroup") {
              _json.plug = "ywm";
            }
            that.$router.push(that.fun.getUrl("goodsorder", {}, _json));
          }
        } else {
          console.log(response.msg);
        }
      });
    },
    openCardGroup(goods_id, optionsId) {
      this.$dialog
        .confirm({
          title: "提示",
          message: "确认开团"
        })
        .then(() => {
          this.confirmOpenCardGroup(goods_id, optionsId);
        })
        .catch(() => {
          this.$emit("popupModeshowChild", false);
        });
    },
    confirmOpenCardGroup(goods_id, optionsId) {
      let that = this;
      this.goodsId = goods_id;

      if (this.fun.isTextEmpty(level_id)) {
        Toast("请选择开团点");
        console.log("请选择开团点");
        return;
      }

      let _json = {
        member_open_group_id: this.goods_info.member_open_card_id,
        group_id: this.$route.params.id,
        goods: JSON.stringify([
          {
            goods_id: that.goodsId,
            option_id: optionsId,
            total: that.goodsCount
          }
        ]),
        level_id: level_id,
        option_level_id: that.option_level_id
      };
      $http.post("plugin.ywm-fight-groups.frontend.controllers.fight-groups.card-open-group", _json, "加载中").then(response => {
        this.$toast(response.msg);
        if (response.result === 1) {
          this.$emit("popupModeshowChild", false);
          // location.reload();
          this.$router.push(this.fun.getUrl("ywmGroupsMyGroups", {}));
        } else {
          console.log(response.msg);
        }
      });
    },
    showGroupMore() {
      let isBindDrainageScene = bindDrainageScene({
        scene: 8,
        title: this.goodsInfo.title
      });
      if (!isBindDrainageScene) return; //爆客码绑定场景

      if (this.goods_info.join_status === false && (this.goods_type === "GroupGoods" || this.goods_type === "ywmGroup")) {
        Toast({
          message: "今日该活动已达到参与次数",
          icon: "info-o"
        });
        return false;
      }
      this.$emit("showGroupList", true);
    },
    // 抢团插件 =================================
    openOrder(type) {
      submitActionTag = type == 1 ? "snatchLeader" : "snatchGroup";
      this.$emit("popupModeshowChild", true);
    },
    //获取数据列表
    checkActivity() {
      let that = this;
      $http
        .get(
          "plugin.snatch-regiment.api.index.getSnatchData",
          { art: "inspectOverrun", leader_id: 0, at_id: this.goodsInfo.activity_id, option_id: optionsId, goods_id: this.$route.params.id, total: this.goodsCount },
          ""
        )
        .then(
          response => {
            if (response.result === 1) {
              that.isCheckActivity = true;
              if (submitActionTag == "snatchLeader") {
                //团长开团不参与中奖
                this.$dialog
                  .confirm({
                    title: "提示",
                    message: "开团后不参与中奖？"
                  })
                  .then(() => {
                    that.OpenLeader();
                  })
                  .catch(() => {
                    // Toast("已取消");
                  });
              } else if (submitActionTag == "snatchGroup") {
                //团长开团参与中奖
                this.openSnatchGroup();
              }
            } else {
              that.isCheckActivity = false;
              Toast(response.msg);
            }
          },
          response => {}
        );
    },
    OpenLeader() {
      let that = this;
      $http.get("plugin.snatch-regiment.api.team.OpenLeader", { at_id: this.goodsInfo.activity_id, goods_id: goods_id }).then(
        response => {
          if (response.result === 1) {
            Toast("开团成功！");
            that.$router.push(that.fun.getUrl("grab_group_my", {}));
          } else {
            Toast(response.msg);
          }
        },
        response => {}
      );
    },
    openSnatchGroup() {
      if (!this.isCheckActivity) {
        Toast("抱歉，您已超出限制条件");
        return;
      }
      if (this.goodsCount == 0) {
        Toast("抱歉，库存不足");
        return;
      }
      let that = this;
      let goods = [];
      goods.push(goods_id);
      $http.get("from.div-from.isDisplay", { goods_ids: JSON.stringify(goods) }, "加载中").then(
        response => {
          if (response.result === 1) {
            if (response.data.status && !response.data.member_status) {
              that.$dialog
                .confirm({ message: "购买跨境商品,请补充您的个人信息" })
                .then(() => {
                  that.$router.push(
                    that.fun.getUrl("myinfo", {
                      tag: "grabGroup_open",
                      goodsId: goods_id,
                      at_id: that.goodsInfo.activity_id, //活动ID
                      optionsId: optionsId,
                      total: that.goodsCount
                    })
                  );
                })
                .catch(() => {});
            } else {
              that.$router.push(
                that.fun.getUrl(
                  "goodsorder",
                  {},
                  {
                    tag: "-2",
                    orderType: "grabGroup_open",
                    optionsId: optionsId,
                    goodsId: goods_id, //活动商品ID
                    at_id: that.goodsInfo.activity_id, //活动ID
                    total: that.goodsCount
                  }
                )
              );
            }
          } else {
            console.log(response.msg);
          }
        },
        response => {
          console.log(response);
          that.isGoods = false;
        }
      );
    },
    // 抢团插件 end ================================

    // 新零售 插件 ======================
    newRetailOrder() {
      let _json = {
        orderType: "newRetail",
        tag: "-2",
        goodsId: this.$route.params.id,
        optionsId: optionsId,
        total: this.goodsCount
      };
      // submitActionTag == "newRetail_1" || submitActionTag == "newRetail_2";
      //自主进货下单：相当于不需要配送方式的虚拟商品
      //retail_state: 0-自由零售 1-成为代理商订单 2-自由发货 3-线上零售 4-进货订单 5-销售代理套餐订单
      let retail_state = null;
      if (this.$route.params.mode == 3 && submitActionTag == "newRetail_2") {
        //自由进货
        retail_state = 4;
      } else if (this.$route.params.mode == 2 && submitActionTag == "newRetail_2") {
        //代理套餐 的 立即购买
        _json.NRLevelId = this.levelModel;
        retail_state = 1;
      } else if (this.$route.params.mode == 1 && submitActionTag == "newRetail_2") {
        //自由零售
        retail_state = 0;
      } else if (this.$route.params.mode == 2 && submitActionTag == "newRetail_1") {
        //代理套餐 的代理销售。跳转二维码页面
        retail_state = 5;
        this.agentSales(optionsId, this.goodsCount);
        return;
      }
      _json.retail_state = retail_state;
      this.$router.push(this.fun.getUrl("goodsorder", {}, _json));
    },
    agentSales(_optionsId, goodsCount) {
      $http
        .post(
          "plugin.new-retail.frontend.index.agentSales",
          { goods_id: this.$route.params.id, goods_option: _optionsId, goods_num: goodsCount, level_id: this.levelModel, goods_name: this.goodsInfo.title },
          ""
        )
        .then(response => {
          if (response.result === 1) {
            this.$router.push(this.fun.getUrl("newRetail_agencyPackage", { id: response.data.id }));
          } else {
            Toast(response.msg);
          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    newRetailBuy(type) {
      // submitActionTag : 代理套餐||newRetail_1，立即购买||newRetail_2
      submitActionTag = type;
      this.$emit("popupModeshowChild", true);
    },

    //跳转主页
    gotoHome() {
      if (this.goods_type == "grab_group") {
        this.$router.push(this.fun.getUrl("grab_group_home", {}));
      } else if (this.goods_type == "supplierGoods") {
        //增加区分 供应商首页和商城首页
        this.supplierListShow = true;
        return;
      } else if (this.$route.query.tag && this.$route.query.tag == "vending_machine") {
        this.$router.push(this.fun.getUrl("vending_machine", {}, { machine_id: this.$route.query.machineId }));
      } else {
        this.$router.push(this.fun.getUrl("home", {}));
      }
    },
    gotoOrder() {
      this.$router.push(this.fun.getUrl("zhpMyGroups", {}));
    },
    //律师
    payHandle() {
      if (!this.lawyer_Info.name) {
        return this.$toast("请选择律师");
      }
      if (this.lawyer_Info.service_type == "tel" && this.lawyer_Info.status == 0) {
        return this.$toast("律师休息，暂不能购买电话咨询服务");
      }

      let json = {
        goods_id: this.$route.params.id,
        l_id: this.lawyer_Info.l_id,
        price: this.lawyer_Info.price,
        service_type: this.lawyer_Info.service_type == "tel" ? 1 : 2,
        l_name: this.lawyer_Info.l_name,
        lf_id: this.lawyer_Info.lf_id,
        lf_name: this.lawyer_Info.lf_name,
        service_day: this.lawyer_Info.service_day,
        lf_province_name: this.lawyer_Info.lf_province_name,
        lf_city_name: this.lawyer_Info.lf_city_name,
        lf_area_name: this.lawyer_Info.lf_area_name,
        lf_street_name: this.lawyer_Info.lf_street_name,
        lf_address_detail: this.lawyer_Info.lf_address_detail
      };
      if (this.lawyer_Info.service_day) {
        json.service_day = this.lawyer_Info.service_day;
      }
      $http.post("plugin.lawyer-platform.frontend.controllers.create", json).then(res => {
        if (res.result == 1) {
          let order_ids = res.data.order_ids;
          this.$router.push(this.fun.getUrl("orderpay", { order_ids }));
        } else {
          this.$toast(res.msg);
        }
      });
    },

    zhpGroupOrder() {
      // 珍惠拼参团
      let _json = {
        tag: "zhpGroup",
        goodsId: this.goods_info.goods_id,
        activity_id: this.$route.params.id,
        optionsId: optionsId,
        total: this.goodsCount
      };
      this.$router.push(this.fun.getUrl("goodsorder", {}, _json));
    },

    callPhone() {
      if (!this.goodsInfo.contact_tel) return this.$toast("抱歉，暂无设置联系电话");
      window.location.href = "tel://" + this.goodsInfo.contact_tel;
    },
    getTimeAppointment(data) {
      this.reserveData = data;
      let id = data.item.id;
      let index = this.goods_plugin.reserve_simple_goods.objs.findIndex(item => item.id == id);
      this.$refs.AppointmentPopup.reserveData = data;
      // this.$refs.AppointmentPopup.current_index = index;
      this.$refs.AppointmentPopup.current_index = data.current_index;
    }
  }
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
.pcStyle {
  #foot {
    width: 375px !important;
  }

  .lawyer_platform_goods {
    width: 375px !important;
  }
}

.posDiv {
  width: 100%;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  background: #fff;
  height: 3.13rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -0.06rem 0.22rem 0 rgba(185, 185, 185, 0.45);
  padding: 0.53rem 0.94rem 0.53rem 0.88rem;

  .posDiv_none {
    color: #9c9c9c;
  }

  .leftBox {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.75rem;
    color: #3e3e3e;
  }

  .RightBox {
    // padding: 0.3rem 1.84rem;
    // box-sizing: border-box;
    border-radius: 1.8rem;
    height: 2.56rem;
    width: 100%;
    line-height: 2.56rem;
    background-color: #f42a26;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    font-size: 0.69rem;
  }
}

#foot {
  position: fixed;
  bottom: 0;
  width: 100%;
  border-top: 0 solid #e2e2e2;
  z-index: 2;
  padding: 0;
  height: 3.0625rem;
  display: flex;
  align-items: center;
  background: #fff;

  .cservice {
    height: 3.0625rem;
    text-align: center;
    flex: 2;
    font-size: 12px;

    a {
      height: 3.0625rem;
      text-align: center;
      display: block;
      color: #333;

      i {
        display: block;
        font-size: 18px;
        margin: 0.25rem 0;
        color: #48a3f1;
      }
    }
  }

  .addfav {
    border-top: solid 0.0625rem #ebebeb;
    color: #666;
    height: 3.0625rem;
    text-align: center;
    flex: 1.5;
    font-size: 12px;

    i.normal {
      font-size: 1.375rem;
      color: #666;
    }

    i.active {
      font-size: 1.375rem;
      color: #f7ba2a;
    }

    i {
      color: #666;
      font-size: 1.375rem;
    }

    i.icon-goods_car {
      color: #666;
    }

    span {
      display: inline-block;
      width: 100%;
      margin-top: 0.25rem;
      color: #333;
    }

    li {
      color: #666;
    }
  }

  .addfav.nocar {
    background: #fff;
  }

  .cart.cell {
    background: #ff9500;
    height: 3.0625rem;
    text-align: center;
    border: none;
    color: #fff;
    flex: 3;
    font-size: 15px;
    line-height: 3.0625rem;
  }

  .cart.cell.nocar {
    background: #ccc;
  }

  .buy.cell {
    background: #dd2727;
    height: 3.0625rem;
    text-align: center;
    border: none;
    color: #fff;
    flex: 3;
    font-size: 15px;
    line-height: 3.0625rem;
  }

  .buy.cell.nocar {
    background: #ccc;
  }

  .cart-btn .time {
    background: #dd2727;
    height: 3.0625rem;
    text-align: center;
    border: none;
    color: #fff;
    font-size: 14px;
    line-height: 3.0625rem;
  }
}

.group_btn {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 3.125rem;
  background: #fff;
  border-top: solid 0.0625rem #ebebeb;

  .item {
    height: 3.125rem;
    display: flex;

    .item_a {
      width: 3.75rem;
      padding: 0.1875rem 0;

      .iconfont {
        color: #666;
        font-size: 1.5rem;
      }

      span {
        color: #666;
        font-size: 12px;
        display: block;
      }
    }

    .item_b {
      width: 9.8438rem;
      padding: 0.1875rem 0;
      background: rgba(241, 83, 83, 0.6);
      color: #fff;
      font-size: 14px;

      span {
        display: block;
      }

      font {
        font-size: 18px;
      }
    }

    .item_c {
      // width: 9.8438rem;
      padding: 0.1875rem 0;
      background: #f15353;
      color: #fff;
      font-size: 14px;
      flex: 1;

      span {
        display: block;
      }

      font {
        font-size: 18px;
      }
    }

    .endClass {
      background: #c9c9c9 !important;
    }
  }
}
//律师
.lawyer_platform_goods {
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  position: fixed;
  bottom: 0;
  width: 100%;
  border-top: 0 solid #e2e2e2;
  z-index: 5;
  height: 3.0625rem;
  display: flex;
  align-items: center;
  background: #fff;

  &-left {
    display: flex;
    flex-direction: column;
    text-align: left;
  }

  &-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 7rem;
    height: 2.5rem;
    border-radius: 20px;
    background-color: #daa032;
    text-align: center;
    color: #fff;
  }
}

.adressNone {
  position: absolute;
  top: -1.4rem;
  left: 0;
  width: 100%;
  background: #f5cda9;
  font-size: 1rem;
  color: #f3780b;
  text-align: center;
}

.isgroupIcon {
  font-size: 18px;
}
</style>
